<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><!DOCTYPE html>
        <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
        <head>
            <th:block th:include="include :: header('新增入库记录')" />
        </head>
<body  >
<div class="container-div">
    <el-divider content-position="left" style="margin-bottom: 20px">入库记录信息</el-divider>
    <el-form   label-position="left" :model="insert.billInRecord.info" ref="insertForm" label-width="120px" :rules="insert.billInRecord.rules" class="demo-ruleForm">

        <el-form-item   label="箱号" >
            <el-input v-model="insert.billInRecord.info.boxCode"></el-input>
        </el-form-item>



        <el-form-item   label="批次" >
            <el-input v-model="insert.billInRecord.info.batch"></el-input>
        </el-form-item>

        <el-form-item   label="生产日期" >
            <el-input v-model="insert.billInRecord.info.pd"></el-input>
        </el-form-item>

        <el-form-item   label="失效日期" >
            <el-input v-model="insert.billInRecord.info.exp"></el-input>
        </el-form-item>

        <el-form-item   label="接收数量" >
            <el-input v-model="insert.billInRecord.info.acceptQuantity"></el-input>
        </el-form-item>

        <el-form-item   label="接收日期" >
            <el-input v-model="insert.billInRecord.info.acceptTime"></el-input>
        </el-form-item>


    </el-form>
    <div style="margin-left: 40%">
        <el-button type="primary" @click="save()">保存</el-button>
        <el-button type="info" @click="closeModal()">返回</el-button>
    </div>
</div>

<div th:include="include::footer"></div>
<script type="text/javascript" charset="UTF-8">
    var prefix = ctx + "billInRecord"
    var app = new Vue({
        el: '.container-div',
        data: {
            insert:{
                billInRecord:{
                    info:{},
                    rules:{

                    }
                }
            }
        },
        methods:{
            /*关闭此页面*/
            closeModal:function(){
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            },
            save:function(){
                var that = this;
                /*校验billMaster数据*/
                this.$refs['insertForm'].validate((valid) => {
                    if (valid) {
                        var data = JSON.stringify(that.insert.billInRecord.info)
                        $.ajax({
                            cache : true,
                            type : "POST",
                            url :  "/billInRecord/add",
                            data : data,
                            dataType:"json",
                            contentType: "application/json;charset-UTF-8",
                            async : false,
                            beforeSend: function () {
                                $.modal.loading("正在处理中，请稍后...");
                            },
                            error : function(request) {
                                $.modal.alertError(request.msg);
                                $.modal.closeLoading();
                            },
                            success : function(data) {
                               // $.modal.alertSuccess("保存成功！");

                                that.closeModal();
                                parent.$.modal.msgSuccess("保存成功");
                                parent.$.table.refresh();
                            }
                        });
                    }else{
                        return false;
                    }
                });
            }
        }
    })
</script>
</body>
</html>
</title>
</head>
<body>

</body>
</html>